//
//  Loan_RightImageView.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/5.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Loan_RightImageView.h"

@interface Loan_RightImageView()



@end

@implementation Loan_RightImageView

- (instancetype)init {
    
    self = [super init];
    
    if (self) {
        
        //标签名称
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(self.mas_left);
            make.centerY.mas_equalTo(self);
            make.height.mas_equalTo(15);
            make.width.mas_equalTo(75);
        }];
        
        
        [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerY.mas_equalTo(self.titleLabel.mas_centerY).offset(0);
            make.size.mas_equalTo(CGSizeMake(22, 22));
            make.right.mas_equalTo(self.mas_right);
        }];
        //设置底部线条
        [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(self.titleLabel.mas_left);
            make.right.mas_equalTo(self.mas_right);
            make.bottom.mas_equalTo(self.mas_bottom);
            make.height.equalTo(@0.5f);
        }];
        
        UITapGestureRecognizer *gestureR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showPackView)];
        
        [self addGestureRecognizer:gestureR];
        
        [self.writeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerY.mas_equalTo(self.titleLabel.mas_centerY).offset(0);
            make.left.mas_equalTo(self.titleLabel.mas_right);
            make.height.mas_equalTo(ApplicationTextFieldHeight);
            make.right.mas_equalTo(self.rightImageView.mas_left).offset(0);
        }];
        
        
    }
    
    return self;
}

- (void)showPackView {
    
    if ([self.delegate respondsToSelector:@selector(showSelectPeakView:)]) {
        [self.delegate showSelectPeakView:self];
    }
}

- (MSQTextField *)writeTextField {
    
    if (!_writeTextField) {
        _writeTextField = [[MSQTextField alloc] init];
        _writeTextField.font = [UIFont boldSystemFontOfSize:15];;
        _writeTextField.textColor = ThemeMaoBlackColor;
        _writeTextField.userInteractionEnabled = NO;
        _writeTextField.textAlignment = NSTextAlignmentRight;
        [self addSubview:_writeTextField];
    }
    return _writeTextField;
}

- (UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor = ThemeMaoBlackColor;
        
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UIImageView *)lineImageView {
    
    if (!_lineImageView) {
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.backgroundColor = ThemeMaoLineColor;
        _lineImageView.layer.cornerRadius = 0.25;
        _lineImageView.layer.masksToBounds = YES;
        [self addSubview:_lineImageView];
    }
    return _lineImageView;
}

- (UIImageView *)rightImageView {
    
    if (!_rightImageView) {
        _rightImageView = [[UIImageView alloc] init];
        [_rightImageView setContentMode:UIViewContentModeScaleAspectFit];
        _rightImageView.userInteractionEnabled = YES;
        _rightImageView.image = [UIImage imageNamed:@"loan_rightGo"];
        [self addSubview:_rightImageView];
    }
    return _rightImageView;
}


@end
